package com.gugee.common.web.system.promise.validate;

import com.gugee.common.web.system.promise.Limit;
import com.gugee.common.web.system.promise.RequestLimit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ValidateFactory {
    @Autowired
    PropertyLimit propertyLimit;
    @Autowired
    ViewDataLimit viewDataLimit;
    @Autowired
    TimeLimit countPropertyLimit;
    @Autowired
    CountLimit countLimit;
    @Autowired
    RoleLimit roleLimit;
    @Autowired
    ReportLimit reportLimit;

    public  Validate getValidate(RequestLimit limitAnnotation){
        if(limitAnnotation.validateType().getValue() == Limit.PROPERTY_LIMIT.getValue()) {
            return propertyLimit;
        }else if( limitAnnotation.validateType().getValue() == Limit.VIEW_DATA_LIMIT.getValue()){
            return viewDataLimit;
        }else if( limitAnnotation.validateType().getValue() == Limit.DAY_LIMIT.getValue() || limitAnnotation.validateType().getValue() == Limit.MONTH_LIMIT.getValue()){
            return countPropertyLimit;
        }else if( limitAnnotation.validateType().getValue() == Limit.COUNT_LIMIT.getValue()){
            return countLimit;
        }else if( limitAnnotation.validateType().getValue() == Limit.ADD_SUB_USER.getValue() || limitAnnotation.validateType().getValue() == Limit.ADD_MY_TIKTOK_LIMIT.getValue()){
            return countLimit;
        }else if( limitAnnotation.validateType().getValue() == Limit.ROLE_LIMIT.getValue()){
            return roleLimit;
        }else if( limitAnnotation.validateType().getValue() == Limit.REPORT_LIMIT.getValue()){
            return reportLimit;
        }
        return null;
    }
}
